package com.gx.smart.building.ui.swap

import com.gx.smart.base.BaseActivityV2
import com.gx.smart.building.R
import com.gx.smart.building.ui.swap.fragment.SwapWorkFragment
import com.gx.smart.building.ui.swap.model.SaveSwapContentMessageEvent
import com.mylhyl.circledialog.CircleDialog
import org.greenrobot.eventbus.EventBus

class SwapWorkActivity : BaseActivityV2() {
    override fun onBindLayout(): Int = R.layout.activity_swap_work

    override fun getToolbarTitle(): String = ""

    override fun enableToolbar(): Boolean = false

    override fun onBackPressed() {
        if ((supportFragmentManager.fragments[0] as SwapWorkFragment).position == 0) {
            CircleDialog.Builder()
                .setTitle("保存草稿")
                .setText("您确定要保存草稿吗？")
                .setPositive("确定") { EventBus.getDefault().post(SaveSwapContentMessageEvent()) }
                .setNegative("取消") { super.onBackPressed() }
                .show(supportFragmentManager)
        } else {
            super.onBackPressed()
        }
    }
}